import { useAppConfig } from '@vben/hooks';

const { historyMapIP } = useAppConfig(import.meta.env, import.meta.env.PROD);
/**
 * 获取指定年份的 style.json URL
 */
const getHistoryMapStyle = (year: string) => {
  return `http://${historyMapIP}/style/${year}`;
};

/**
 * 获取默认 style.json URL
 */
const getDefaultStyle = (formatted: string) => {
  return `http://${historyMapIP}/style/${formatted}`;
};

/**
 * 获取矢量瓦片 URL 模板字符串
 */
const getHistoryTilesURL = (year: string) => {
  return `http://${historyMapIP}/tiles/${year}/{z}/{x}/{y}.pbf`;
};

export const historyApi = {
  getHistoryMapStyle,
  getDefaultStyle,
  getHistoryTilesURL,
};
